package com.example.sfm.controller;


import com.example.sfm.constant.MessageConstants;
import com.example.sfm.pojo.dto.GradesQueryDto;
import com.example.sfm.result.Result;
import com.example.sfm.service.IGradesService;
import com.example.sfm.utils.ThreadLocalUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author sfm
 * @since 2025-03-07
 */
@RestController("userGradesController")
@RequestMapping("/user/grades")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "学生成绩相关接口", description = "学生成绩相关接口")
public class GradesController {
    private final IGradesService gradesService;

    /**
     * 分页查询成绩
     */
    @GetMapping("/list")
    @Operation(summary = "分页查询成绩", description = "根据查询条件分页查询成绩信息")
    public Result<?> listGrades(@ParameterObject GradesQueryDto dto) {
        log.info("查询成绩列表: {}", dto);
        dto.setStudentId(ThreadLocalUtil.getId());
        return Result.success(gradesService.listGrades(dto), MessageConstants.SELECT_OK);
    }
}
